package com.hspedu.collection_;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @Author Stringzhua
 * @Date 2024/3/10 21:56
 * description:
 */
@SuppressWarnings("all")
public class ArrayListDetail {
    public static void main(String[] args) {
        /*
        * ArrayList 是线程不安全的,源码中没有synchronized的修饰
        *  public boolean add(E e) {
        ensureCapacityInternal(size + 1);  // Increments modCount!!
        elementData[size++] = e;
        return true;
        }
        * */
        ArrayList arrayList = new ArrayList();
        arrayList.add(null);
        arrayList.add("jack");
        arrayList.add(null);
        arrayList.add("hsp");
        System.out.println("arrayList = " + arrayList);
        Iterator iterator = arrayList.iterator();
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println("next = " + next);
        }
    }
}
